home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Aminet 5
/
Aminet 5 - March 1995.iso
/
Aminet
/
text
/
misc
/
PWIDXM.lha
/
MakeIndex
next >
Wrap
Text File
|
1994-10-12
|
4KB
|
227 lines
/* COPYRIGHT 1992 by Software Industry & General Hardware */
/* All Rights Reserved */
/* Software Industry & General Hardware is not responsible
for loss of data, damage to an files, or anything else.
Use of this product is at your own risk. */
SIGNAL ON BREAK_C
SIGNAL ON BREAK_D
SIGNAL ON BREAK_E
SIGNAL ON BREAK_F
SIGNAL ON SYNTAX
SIGNAL ON IOERR
OPTIONS RESULTS
CALL OPEN(ER, "T:ErrorFile", "WRITE" )
CALL WRITELN(ER, "Version V1.01B")
/* Check for existing Phrase File */
IF ~EXISTS( "T:PhraseFile" ) THEN DO
REQUEST1 '"No Phrase File Found."'
EXIT 0
END
/* If we got here then the Phrase file exists */
IF EXISTS( "T:TrashPhraseFile" ) THEN ADDRESS COMMAND "DELETE > NIL: T:TrashPhraseFile"
ADDRESS COMMAND "RENAME T:PhraseFile T:TrashPhraseFile"
ADDRESS COMMAND "SORT T:TrashPhraseFile T:PhraseFile"
ADDRESS COMMAND "DELETE T:TrashPhraseFile"
/* Phrase file is sorted and stripped of dups */
CALL OPEN(PF, "T:PhraseFile", "READ" )
ADDRESS 'ProWrite'
DRAWOFF
DOCNAME
DocumentName = RESULT
Window DocumentName
CurDoc = DocumentName
IF CurDoc == "" THEN DO
REQUEST1 '"NO Index Generated"'
EXIT 0
END
MOVEBEGINDOC
CURRENTPAGE
StartPage = RESULT
MOVEENDDOC
CURRENTPAGE
EndingPage = RESULT
IF RC ~= 0 THEN DO
WRITLEN(ER, "EndingPage: "||EndingPage)
WRITELN(ER, "RC got an error on getting Ending page Result: "||RC)
EXIT RC
END
EndingPage = EndingPage + 1
CALL WRITELN(ER, "Ending Page: "||EndingPage)
CALL WRITELN(ER, "StartPage : "||StartPage )
EndingPage = 3
DRAWOFF
CurDoc = CurDoc||".idx"
NEW
COLORBLACK
ALIGNCENTER
TYPE "Index for "
TYPE DocumentName
NEWPARAGRAPH
TABLEFT
ADDTAB 3000
ALIGNLEFT
SAVEAS CurDoc
CLOSE
OPEN CurDoc
Window DocumentName
AlphaGroup = ""
MyPFCount = 1
MOREPAGES:
SETFIND WHOLEWORD NOMATCHCASE
CALL WRITELN(ER, "MorePages")
WindowNoFront DocumentName
CurPage = D2C(9) /* Tab */
Phrase = READLN(PF)
IF EOF(PF) THEN SIGNAL NOMOREPF
MyPFCount = MyPFCount + 1
IF MyPFCount == 15 THEN DO
CALL WRITELN(ER, "MyPFCount exceeds 15")
EXIT(10)
END
Temp = TRANSLATE(Phrase)
Temp = LEFT(Temp,1)
IF Temp ~= AlphaGroup THEN CALL NextAlphaHeader()
WindowNoFront DocumentName
MOVEBEGINDOC
SETFINDTEXT Phrase
CURRENTPAGE
LastPage = RESULT - 1
ThisPage = LastPage + 1
Done = 0
MySearchCount = 0
NOTDONE:
SIGNAL ON ERROR
FINDNEXT NOPROMPT
SIGNAL GOON
ERROR:
IF RC == 10 THEN SIGNAL DONEXTENTRY
GOON:
Done = RC
MySearchCount = MySearchCount + 1
IF MySearchCount == 10 THEN DO
CALL WRITELN(ER, "MySearchCount exceeds 10")
EXIT(10)
END
CURRENTPAGE
ThisPage = RESULT
IF Done == 0 THEN DO
IF ThisPage ~= LastPage THEN DO
CurPage = CurPage||ThisPage||" "
LastPage = ThisPage
IF (ThisPage + 1) == EndingPage THEN SIGNAL DONEXTENTRY
END
ELSE DO
NextPage = ThisPage + 1
GOTOPAGE NextPage
END
END
ELSE DO
CURRENTPAGE
ThisPage = RESULT
NextPage = ThisPage + 1
GOTOPAGE NextPage
END
SIGNAL NOTDONE
DONEXTENTRY:
/* DRAWON */
Tab = D2C(9)
Window CurDoc
MOVEENDDOC
TYPE Phrase
TYPE Tab
TYPE CurPage
NEWPARAGRAPH
SAVE CurDoc
/* DRAWOFF */
WindowNoFront DocumentName
SIGNAL MOREPAGES
NOMOREPF:
DRAWON
Window CurDoc
SELECTALL
COLORBLACK
SPACESINGLE
CURSORRIGHT
SAVE
/* if an error occured in obtaining our phrase then return
to ProWrite(TM) with complaint
*/
/* return with success status */
CLOSE(ER)
EXIT(0)
NextAlphaHeader:
WindowNoFront CurDoc
MOVEENDDOC
COLORBLACK
ALIGNCENTER
AlphaGroup = LEFT(Phrase,1)
AlphaGroup = TRANSLATE( AlphaGroup )
STYLEBOLD
TYPE "- "
TYPE AlphaGroup
TYPE " -"
STYLEPLAIN
NEWPARAGRAPH
ALIGNLEFT
WindowNoFront DocumentName
RETURN 0
BREAK_C:
BREAK_D:
BREAK_E:
BREAK_F:
CALL WRITELN(ER, 'Got a FAILURE error.')
DIFFERROR:
CALL WRITELN(ER, 'Got an ERROR error.')
SYNTAX:
CALL WRITELN(ER, 'Got a SYNTAX error.')
IOERR:
CALL WRITELN(ER, 'Got an IOERR error.')
CALL WRITELN(ER, "RC: "RC)
CALL WRITELN(ER, "Got an error")
CALL WRITELN(ER, "Error was at line: "SIGL)
CALL WRITELN(ER, "Error was "RC)
CALL WRITELN(ER, ErrorText(RC))
CLOSE(ER)
EXIT 0